/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Marks;

import Admission.AdmissionBean;
import Course.CourseBean;
import ExamType.ExamTypeBean;
import Subject.SubjectBean;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author mishra
 */
public class StudentResultDetails extends HttpServlet {

    
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, SQLException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        HttpSession session=request.getSession();
        try {
            String email=request.getParameter("uid");
            int Aid=0;
            Aid=Admission.Query.getAdmiId(email);
            if(Aid!=0){
                AdmissionBean adb=Admission.Query.viewSpecific(Aid);
                if(adb.getAddmissionId()!=0){
                    CourseBean cob=adb.getCourseBean();
                    out.println("<div id='cor' stu;e='float: left'><b>Course Name</b>&nbsp&nbsp<span class=\"label label-success\">"+cob.getCourseName()+"</span></div>");
                    out.println("<div id='ses' style='float: right; margin-top: -17px;'><b>Session</b>&nbsp&nbsp<span class=\"label label-warning\">"+adb.getStudentSession()+"</span></div>");
                    }
            }
            Vector<MarksBean> list=Marks.Query.viewResult(email);
            if(!list.isEmpty()){
            Iterator it=list.iterator();
            while(it.hasNext()){
                MarksBean mb=(MarksBean) it.next();
                SubjectBean sb=mb.getSubjectBean();
                CourseBean cb=mb.getCourseBean();
                AdmissionBean ab=mb.getAdmissionBean();
                ExamTypeBean etb=mb.getExamTypeBean();
                
                  out.println("<legend>Semester&nbsp"+mb.getSem()+"</legend");
//                out.println(sb.getSubjectName());
//                out.println(etb.getExamTypeName());
//                
            }
            }
            else{
               out.println("<div>");
               out.println("<b>No Record Found</b>");
               out.println("</div>");
            }
           
        } finally {
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            processRequest(request, response);
        } catch (SQLException ex) {
            Logger.getLogger(StudentResultDetails.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            processRequest(request, response);
        } catch (SQLException ex) {
            Logger.getLogger(StudentResultDetails.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
